<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>this关键字的指向</title>
</head>
<body>
<div>标签对象</div>
<script>
//    1. 全局作用域内，指向的是window对象
    console.log(this)
//  2. 调用事件的标签对象
var div = document.querySelector('div')
    div.onclick = function(){
        console.log(this)
    }
//    3.构造函数自身
    function Cat(name, age){
        console.log(this.name)
        this.name = name
        this.age = 'age'
    }
    Cat()
//    4.普通的对象
    var obj = {
        name:'yana',
        age:14,
        run:function(){
            console.log(this)
        }
    }
    obj.run()
</script>
</body>
</html>
